home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / c / pro22 / lsgetcur.c < prev    next >
Text File  |  1990-06-20  |  2KB  |  78 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)lsgetcur.c    1.4 - 90/06/20" */
  5.  
  6. /* ansi headers */
  7. #include <errno.h>
  8. /*#include <string.h>*/
  9.  
  10. /* library headers */
  11. #include <blkio.h>
  12.  
  13. /* local headers */
  14. #include "lseq_.h"
  15.  
  16. /*man---------------------------------------------------------------------------
  17. NAME
  18.      lsgetcur - get lseq cursor
  19.  
  20. SYNOPSIS
  21.      #include <lseq.h>
  22.  
  23.      int lsgetcur(lsp, lsposp)
  24.      lseq_t *lsp;
  25.      lspos_t *lsposp;
  26.  
  27. DESCRIPTION
  28.      The lsgetcur function gets the current cursor position of lseq
  29.      lsp and copies it to the location pointed to by lsposp.  A lseq
  30.      position saved with lsgetcur can be used to reposition to a
  31.      record using lssetcur.  It is important to remember that an lseq
  32.      position saved with lsgetcur is not valid after that lseq has
  33.      been unlocked.
  34.  
  35.      lsgetcur will fail if one or more of the following is true:
  36.  
  37.      [EINVAL]       lsp is not a valid lseq pointer.
  38.      [EINVAL]       lsposp is the NULL pointer.
  39.      [LSELOCK]      lsp is not locked.
  40.      [LSENOPEN]     lsp is not open.
  41.  
  42. SEE ALSO
  43.      lssetcur.
  44.  
  45. DIAGNOSTICS
  46.      Upon successful completion, a value of 0 is returned.  Otherwise,
  47.      a value of -1 is returned, and errno set to indicate the error.
  48.  
  49. ------------------------------------------------------------------------------*/
  50. int lsgetcur(lsp, lsposp)
  51. lseq_t *lsp;
  52. lspos_t *lsposp;
  53. {
  54.     /* validate arguments */
  55.     if (!ls_valid(lsp) || lsposp == NULL) {
  56.         errno = EINVAL;
  57.         return -1;
  58.     }
  59.  
  60.     /* check if not open */
  61.     if (!(lsp->flags & LSOPEN)) {
  62.         errno = EINVAL;
  63.         return -1;
  64.     }
  65.  
  66.     /* check if not read locked */
  67.     if (!(lsp->flags & LSLOCKS)) {
  68.         errno = LSELOCK;
  69.         return -1;
  70.     }
  71.  
  72.     /* get current position */
  73.     memcpy(lsposp, &lsp->clspos, sizeof(lsp->clspos));
  74.  
  75.     errno = 0;
  76.     return 0;
  77. }
  78.